package com.sinochem.yunlian.ship.zuul.config;

import com.sinochem.yunlian.ship.cache.api.CacheConfig;
import com.sinochem.yunlian.ship.cache.api.ICacheHandler;
import com.sinochem.yunlian.ship.cache.api.RedisHandler;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;

/**
 * 
 *
 * @author cyp
 * @date 2017/12/05
 */
//@Configuration
public class AppCacheConfig {

	@Value("${spring.redis.host}")
	private String redisHost;
	
	@Value("${spring.redis.database}")
	private int redisDatabase;
	
	@Value("${spring.redis.password}")
	private String password;
	
    @Bean
    public ICacheHandler cacheHandler() {
        CacheConfig cacheConfig = CacheConfig.getInstance();
        cacheConfig.setHost(redisHost);
        cacheConfig.setDatabase(redisDatabase);
        cacheConfig.setPassword(password);
        return new RedisHandler(cacheConfig);

    }
}
